import { request, requestOther } from '@/utils/request';
import type { PageData } from '@/api/model/pageModel';
import type {
  AccesTokenModel,
  userModel,
  assetModel,
  loginQrcodeModel, optLogModel, integralInfoModel, goldInfoModel,
  withdrawInfoModel, withdrawOrderModel
} from '@/api/model/userModel';

const Api = {
  AccountCreate:'/admin/create/account',//管理员创建帐号
  PasswordRegister:'/password/register',
  PasswordLogin:'/password/login',
  PasswordChange:'/password/change',
  VisitorInfo:'/Visitor/info',
  UserInfo: import.meta.env.VITE_API_URL+'/api/user/info',
  AssetInfo: '/capital/info',
  LoginQrCode: 'https://wx.rscode.cn/wechat/pa/login/qrcode',
  OptLog: '/app/opt/log',
  IntegralList: '/capital/integral/list',
  GoldList: '/capital/gold/list',
  WithdrawList: '/asset/withdraw/list',
  FansList: '/user/fans/list',
  WithdrawAccount: '/asset/withdraw/info', //提现帐号
  ApplyWithdraw: '/asset/withdraw/apply', //提现申请
  WithdrawOrder: '/order/withdraw', //提现单查询
  SmsLoginCode: '/sms/login/code', //短信验证码
  SmsLogin: '/sms/login',
  UserList:'/user/list'
};
export function passwordRegister(d : any) {
  return request.post({
    url: Api.PasswordRegister,
    data: d
  })
}
export function passwordLogin(d : any) {
  return request.post({
    url: Api.PasswordLogin,
    data: d
  })
}
export function passwordChange(d:any){
  return request.post({
    url:Api.PasswordChange,
    data:d
  })
}
//获取访客信息
export function featchVisitorInfo()
{
  return request.get<AccesTokenModel>({
    url: Api.VisitorInfo,
  });
}
//用户信息
export function featchUserInfo() {
  return requestOther.get<userModel>({
    url: Api.UserInfo,
  });
}
export function fetchUserList(d:any)
{
	return request.get<PageData<userModel>>({
	  url: Api.UserList + '?page=' + d.page + '&pageSize=' + d.pageSize,
	});
}
//用户资产
export function featchAssetInfo() {
  return request.get<assetModel>({
    url: Api.AssetInfo,
  });
}

//登录短信
export function sendLoginSms(d : any) {
  return request.post({
    url: Api.SmsLoginCode,
    data: d
  })
}
//手机登录
export function phoneLogin(d : any) {
  return request.post({
    url: Api.SmsLogin,
    data: d
  })
}

//登录二维码
export function getLoginQrcode(d:any)
{
  return requestOther.post({
    url:Api.LoginQrCode,
    data:d
  });
}
//创建帐号
export function createAccount(d:any)
{
	return request.post({
	  url: Api.AccountCreate,
	  data: d
	})
}












//用户操作记录
export function getOptList(d : any) {
  return request.get<PageData<optLogModel>>({
    url: Api.OptLog + '?page=' + d.page + '&pageSize=' + d.pageSize,
  });
}

//积分记录
export function getIntegralList(d : any) {
  return request.get<PageData<integralInfoModel>>({
    url: Api.IntegralList + '?page=' + d.page + '&pageSize=' + d.pageSize,
  });
}

//金币记录
export function getGoldList(d : any) {
  return request.get<PageData<goldInfoModel>>({
    url: Api.GoldList + '?page=' + d.page + '&pageSize=' + d.pageSize,
  });
}

//提现记录
export function getWithdrawList(d : any) {
  return request.get<PageData<withdrawInfoModel>>({
    url: Api.WithdrawList + '?page=' + d.page + '&pageSize=' + d.pageSize,
  });
}


//查询粉丝
export function getFansList(d : any) {
  return request.get<userModel>({
    url: Api.FansList + '?page=' + d.page + '&pageSize=' + d.pageSize,
  });
}

//变更提现帐号
export function saveWithdrawAccount(d : any) {
  return request.post<object>({
    url: Api.WithdrawAccount,
    data: d
  });
}

//提现申请
export function applyWithdraw(d : any) {
  return request.post<object>({
    url: Api.ApplyWithdraw,
    data: d
  });
}

//查提现单
export function getWithdrawOrder(d : any) {
  return request.get<withdrawOrderModel>({
    url: Api.WithdrawOrder + '?orderNo=' + d.orderNo,
  });
}


